package lab04;

import java.io.*;

public class Test02 {
    public static void main(String[] args)throws IOException  {
        File srcFile = new File("d:\\High.mp3");
        File[] fileArray = srcFile.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return new File(dir, name).isFile() && name.endsWith(".source");
            }
        });
        File destFile = new File("d:\\target");
        if (!destFile.exists()) {
            destFile.mkdir();
        }
        for (File file : fileArray) {
            String name = file.getName();
            File newFile = new File(destFile, name);

         BufferedReader br = new BufferedReader(new FileReader(file));
            BufferedWriter bw = new BufferedWriter(new FileWriter(newFile));

            String line = null;
            while((line=br.readLine())!=null){
                bw.write(line);
                bw.newLine();
                bw.flush();
            }
            bw.close();
            br.close();
        }

    }
}
